import React from 'react'
import {WingBlank} from "antd-mobile"
import './MessageCard.css'
import {formatDate,} from "../../utils/dateService";

const MessageCard = props => {
    const {
        message : {
            t,
            title,
            txt,
        },
    } = props
    const date = new Date(Number(t * 1000))
    // if (now > date) return null
    const dataString = formatDate(date, '-')
    const time = date.toTimeString().split(' ')[0]

    return (
        <div className='msg-card-ctn'>
            <WingBlank>
                <p className='msg-data'>
                    {dataString} {time}
                </p>
                <div className='msg-content-ctn'>
                    <p className='msg-content-title'>{title}</p>
                    <p className='msg-content-text'>{txt}</p>
                </div>
            </WingBlank>
        </div>
    )
}

export default MessageCard
